﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UserDepartmentData.cs" company="VDC-IT" author="Longlc">
//   UserDepartmentData class
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace VDC.VONE.DAL
{
    #region

    using System;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using System.Reflection;

    using Microsoft.ApplicationBlocks.Data;

    using VDC.COMMON;
    using VDC.VONE.ENTITIES;

    #endregion

    /// <summary>
    ///     Class access to db UserDepartment
    /// </summary>
    public class UserDepartmentData
    {
        #region Public Methods and Operators

        /// <summary>
        /// Delete UserDepartment by userDepartmentId
        /// </summary>
        /// <param name="userDepartmentId">
        /// param userDepartmentId
        /// </param>
        public void Delete(int userDepartmentId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                var sqlParameters = new[]
                                        {
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.UserDepartmentId, 
                                                userDepartmentId)
                                        };

                SqlHelper.ExecuteNonQuery(
                    SqlHelper.ConnectionString, Constants.StorepProcedure.VOneUserDepartmentDelete, sqlParameters);
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        /// The get default user department.
        /// </summary>
        /// <param name="userId">
        /// The user id.
        /// </param>
        /// <returns>
        /// The <see cref="UserDepartmentEN"/>.
        /// </returns>
        /// <exception cref="Exception">
        /// the exc
        /// </exception>
        public UserDepartmentEN GetDefaultUserDepartment(int userId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                UserDepartmentEN userDepartment = null;
                var reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString, Constants.StorepProcedure.VOneUserDepartmentDefault, userId);
                while (reader.Read())
                {
                    userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    if (!reader.IsDBNull(5))
                    {
                        userDepartment.Default = reader.GetBoolean(5);
                    }
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return userDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        /// Get List UserDepartment By DepartmentId
        /// </summary>
        /// <param name="departmentId">
        /// Param departmentId
        /// </param>
        /// <returns>
        /// List UserDepartment
        /// </returns>
        public IList<UserDepartmentEN> GetUserDepartmentByDepartmentId(int departmentId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                IList<UserDepartmentEN> lstUserDepartment = new List<UserDepartmentEN>();
                SqlDataReader reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString, 
                    Constants.StorepProcedure.VOneUserDepartmentGetByDepartmentId, 
                    departmentId);
                while (reader.Read())
                {
                    UserDepartmentEN userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    lstUserDepartment.Add(userDepartment);
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return lstUserDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        /// Get UserDepartment By Id
        /// </summary>
        /// <param name="userDepartmentId">
        /// Param userDepartmentId
        /// </param>
        /// <returns>
        /// Return UserDepartment
        /// </returns>
        public UserDepartmentEN GetUserDepartmentById(int userDepartmentId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                UserDepartmentEN userDepartment = null;
                var reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString, Constants.StorepProcedure.VOneUserDepartmentGetById, userDepartmentId);
                while (reader.Read())
                {
                    userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    if (!reader.IsDBNull(5))
                    {
                        userDepartment.Default = reader.GetBoolean(5);
                    }
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return userDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        /// The get user department by user department position.
        /// </summary>
        /// <param name="userId">
        /// The user id.
        /// </param>
        /// <param name="departmentId">
        /// The department id.
        /// </param>
        /// <param name="positionId">
        /// The position id.
        /// </param>
        /// <returns>
        /// The <see cref="UserDepartmentEN"/>.
        /// </returns>
        /// <exception cref="Exception">
        /// the ex
        /// </exception>
        public UserDepartmentEN GetUserDepartmentByUserDepartmentPosition(int userId, int departmentId, int positionId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                UserDepartmentEN userDepartment = null;
                var reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString, 
                    Constants.StorepProcedure.VOneUserDepartmentGetByUserDepartmentPosition, 
                    userId, 
                    departmentId, 
                    positionId);
                while (reader.Read())
                {
                    userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    if (!reader.IsDBNull(5))
                    {
                        userDepartment.Default = reader.GetBoolean(5);
                    }
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return userDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        ///     Get list all UserDepartment
        /// </summary>
        /// <returns>Return list all UserDepartment</returns>
        public IList<UserDepartmentEN> GetUserDepartments()
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                IList<UserDepartmentEN> lstUserDepartment = new List<UserDepartmentEN>();
                SqlDataReader reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString, Constants.StorepProcedure.VOneUserDepartmentGetAll);
                while (reader.Read())
                {
                    UserDepartmentEN userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    if (!reader.IsDBNull(5))
                    {
                        userDepartment.Active = reader.GetBoolean(5);
                    }

                    lstUserDepartment.Add(userDepartment);
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return lstUserDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        /// Insert to db UserDepartment
        /// </summary>
        /// <param name="userDepartment">
        /// Paarm UserDepartment
        /// </param>
        /// <returns>
        /// Insert UserDepartment
        /// </returns>
        public int Insert(UserDepartmentEN userDepartment)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                var sqlParameters = new[]
                                        {
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.UserId, userDepartment.UserId), 
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.DepartmentId, 
                                                userDepartment.DepartmentId), 
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.PositionsId, 
                                                userDepartment.PositionsId), 
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.Active, userDepartment.Active), 
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.Default, 
                                                userDepartment.Default)
                                        };

                var result = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnectionString, Constants.StorepProcedure.VOneUserDepartmentInsert, sqlParameters));
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return result;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        /// Update to db UserDepartment
        /// </summary>
        /// <param name="userDepartment">
        /// Param UserDepartment
        /// </param>
        public void Update(UserDepartmentEN userDepartment)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                var sqlParameters = new[]
                                        {
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.UserDepartmentId, 
                                                userDepartment.UserDepartmentId), 
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.UserId, userDepartment.UserId), 
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.DepartmentId, 
                                                userDepartment.DepartmentId), 
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.PositionsId, 
                                                userDepartment.PositionsId), 
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.Active, userDepartment.Active), 
                                            new SqlParameter(
                                                Constants.SqlParamerterName.UserDepartment.Default, 
                                                userDepartment.Default)
                                        };

                SqlHelper.ExecuteNonQuery(
                    SqlHelper.ConnectionString, Constants.StorepProcedure.VOneUserDepartmentUpdate, sqlParameters);
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        #endregion

        /// <summary>
        /// Gets all user department by user unique identifier.
        /// </summary>
        /// <param name="userId">The user unique identifier.</param>
        /// <returns>return list UserDepartmentEN</returns>
        public IEnumerable<UserDepartmentEN> GetAllUserDepartmentByUserId(int userId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                IList<UserDepartmentEN> lstUserDepartment = new List<UserDepartmentEN>();
                SqlDataReader reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString,
                    Constants.StorepProcedure.VOneUserDepartmentGetByUserId,
                    userId);
                while (reader.Read())
                {
                    UserDepartmentEN userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    lstUserDepartment.Add(userDepartment);
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return lstUserDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        /// Gets the user department by user id.
        /// </summary>
        /// <param name="userId">The user id.</param>
        /// <returns>return list user department</returns>
        public IList<UserDepartmentEN> GetUserDepartmentByUserId(int userId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                IList<UserDepartmentEN> lstUserDepartment = new List<UserDepartmentEN>();
                SqlDataReader reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString,
                    Constants.StorepProcedure.VOneUserDepartmentGetByUserIdValid,
                    userId);
                while (reader.Read())
                {
                    UserDepartmentEN userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    lstUserDepartment.Add(userDepartment);
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return lstUserDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        /// Gets the user department by department position.
        /// </summary>
        /// <param name="userDepartmentId">The user department id.</param>
        /// <param name="departmentId">The department id.</param>
        /// <param name="positionId">The position id.</param>
        /// <returns>
        /// return UserDepartmentEN
        /// </returns>
        public UserDepartmentEN GetUserDepartmentByDepartmentPositionUser(int userDepartmentId, int departmentId, int positionId, int userId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                UserDepartmentEN userDepartment = null;
                var reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString, Constants.StorepProcedure.VOneUserDepartmentDepartmentPositionUser, userDepartmentId, departmentId, positionId, userId);
                while (reader.Read())
                {
                    userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    if (!reader.IsDBNull(5))
                    {
                        userDepartment.Default = reader.GetBoolean(5);
                    }
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return userDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        public IList<UserDepartmentEN> UserInRoles_GetRoles(string RoleName, int DepartmentId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                IList<UserDepartmentEN> lstUserDepartment = new List<UserDepartmentEN>();
                SqlDataReader reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString,
                    Constants.StorepProcedure.VOneAspnetUserInRolesGetRoles,
                    RoleName,DepartmentId);
                while (reader.Read())
                {
                    UserDepartmentEN userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    lstUserDepartment.Add(userDepartment);
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return lstUserDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        /// <summary>
        /// Gets the user department by position id.
        /// </summary>
        /// <param name="positionId">The position id.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception"></exception>
        public IList<UserDepartmentEN> GetUserDepartmentByPositionId(int positionId)
        {
            string methodName = MethodBase.GetCurrentMethod().DeclaringType.ToString() + Constants.Dot + MethodBase.GetCurrentMethod().Name;
            LogHelper.Instance.WriteInfo(Constants.Begin + methodName);
            try
            {
                IList<UserDepartmentEN> lstUserDepartment = new List<UserDepartmentEN>();
                SqlDataReader reader = SqlHelper.ExecuteReader(
                    SqlHelper.ConnectionString,
                    Constants.StorepProcedure.VONEUserDepartmentGetByPositionsId,
                    positionId);
                while (reader.Read())
                {
                    UserDepartmentEN userDepartment = new UserDepartmentEN();

                    if (!reader.IsDBNull(0))
                    {
                        userDepartment.UserDepartmentId = reader.GetInt32(0);
                    }

                    if (!reader.IsDBNull(1))
                    {
                        userDepartment.UserId = reader.GetInt32(1);
                    }

                    if (!reader.IsDBNull(2))
                    {
                        userDepartment.DepartmentId = reader.GetInt32(2);
                    }

                    if (!reader.IsDBNull(3))
                    {
                        userDepartment.PositionsId = reader.GetInt32(3);
                    }

                    if (!reader.IsDBNull(4))
                    {
                        userDepartment.Active = reader.GetBoolean(4);
                    }

                    lstUserDepartment.Add(userDepartment);
                }

                reader.Close();
                reader.Dispose();
                LogHelper.Instance.WriteInfo(Constants.End + methodName);
                return lstUserDepartment;
            }
            catch (SqlException ex)
            {
                LogHelper.Instance.WriteError(methodName + Constants.Colon + ex.Message);
                throw new Exception(ex.ToString());
            }
        }

        
    }
}